package com.gopay.scheduler.dao.impl;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.constants.acps.IsolationState;
import com.gopay.common.domain.acps.AcpsResourceIsoLog;
import com.gopay.scheduler.dao.AcpsResourceIsoLogQueryDAO;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * AcpsResourceIsoLogDAO接口
 * Created by xuHui on 2017/07/27.
 */
@Repository("acpsResourceIsoLogQueryDAO")
public class AcpsResourceIsoLogQueryDAOImpl extends BaseDAOImpl<AcpsResourceIsoLog, Integer> implements AcpsResourceIsoLogQueryDAO {

    @Override
    public int findByCreateTs(Date createTs) {
        Map<String, Object> queryMap = new HashMap<>();
        queryMap.put("createTs", createTs);
        queryMap.put("state", IsolationState.ISOLATED.value);
        return findCountByHql("select count(*) from AcpsResourceIsoLog where createTs <= :createTs and state=:state", queryMap);
    }

}